#encoding:utf8

from parameter_parser import parse_parameter
from .triggers.DateTrigger import DateTrigger
from .triggers.CronTrigger import CronTrigger
from .triggers.IntervalTrigger import IntervalTrigger


def get_trigger(trigger_type, trigger_params):
    assert trigger_type in ['date', 'interval', 'cron']
    params = parse_parameter(trigger_params)
    return {
        "date": DateTrigger,
        "cron": CronTrigger,
        "interval": IntervalTrigger
    }[trigger_type](**params)

